from django.db import models
from datetime import datetime
# Create your models here.

from apps.login.models import UserInfo

# 话题模型类
class TopicModel(models.Model):
    topic = models.CharField(verbose_name="话题",max_length=64,blank=True,null=True)
    count = models.IntegerField(verbose_name="参与话题数量",default=0,blank=True,null=True)

    class Meta:
        db_table = "topic"
        verbose_name = "话题信息"
        verbose_name_plural = verbose_name



# 发布功能模型类
class PublishModel(models.Model):
    cover = models.CharField(verbose_name="封面",max_length=128)
    text = models.CharField(verbose_name="发布内容",max_length=255)
    topic = models.ForeignKey(TopicModel,verbose_name="话题id",on_delete=models.CASCADE,null=True,blank=True)
    address = models.CharField(verbose_name='位置', max_length=128, null=True, blank=True,default="浙江")

    user = models.ForeignKey(UserInfo,verbose_name="发布用户",on_delete=models.CASCADE)

    favor_count = models.IntegerField(verbose_name="点赞数",default=0)
    viewer_count = models.IntegerField(verbose_name="浏览数",default=0)
    comment_count = models.IntegerField(verbose_name="评论数",default=0)

    createTime = models.DateTimeField(verbose_name="用户发布时间",auto_now_add=True)


    class Meta:
        db_table = "publish"
        verbose_name = "发布文章"
        verbose_name_plural = verbose_name



# 发布图片模型类  存储在腾讯云服务器中 COS
class PublishImageModel(models.Model):
    key = models.CharField(verbose_name="文件名",max_length=128,help_text="用于后期删除")
    cos_path = models.CharField(verbose_name="文件存储路径",max_length=128)
    article = models.ForeignKey(PublishModel,verbose_name="发布文章信息",on_delete=models.CASCADE)

    class Meta:
        db_table = "publishImage"
        verbose_name = "发布图片"
        verbose_name_plural = verbose_name











